#ifndef FIOCV_HPP
#define FIOCV_HPP

#include <opencv2/opencv.hpp>
#include <iostream>

static bool Save(const cv::Mat &m, std::string fp)
{
    cv::FileStorage fs(fp, CV_STORAGE_WRITE);
    if (fs.isOpened())
    {
        fs << "m" << m;
        fs.release();
        return true;
    }
    std::cout << "Error: can not save result\n";
    return false;
}

static bool Load(cv::Mat &m, std::string fp)
{
    cv::FileStorage fs(fp, CV_STORAGE_READ);
    if (fs.isOpened())
    {
        fs["m"] >> m;
        fs.release();
        return true;
    }
    std::cout << "Failed to open file " << fp << '\n';
    return false;
}

#endif // FIOCV_HPP
